Ext.namespace("ChangeSystem");
ChangeSystem.SysURL_Login = '';
ChangeSystem.SysURL_Main = '';

ChangeSystem.ChangeSystem = function(){
	try{
		Ext.getCmp('change_system').close();
	}catch(e){}
	var account = Ext.state.Manager.get('Cxjava_account');
		var password = Ext.state.Manager.get('Cxjava_password');
		var c_lang = Ext.state.Manager.get('Cxjava_lang');
		var company = Ext.state.Manager.get('Cxjava_company');
	Share.AjaxRequest({
		url : ChangeSystem.SysURL_Login,
		params   : {
            account  : account,
            password : password,
            company  : company,
            lang	 : c_lang
        },
        showMsg  : false,
        callback : function(json){
        	location.href = ChangeSystem.SysURL_Main;
        }
	});
};

Ext.define('HIT.view.ChangeSystem',{
	extend:'Ext.window.Window',
	alias:'changesystem',
	
	height:70,
    width:300,
    frame:true,
    constrain:true,
    resizable:false,
    id:'change_system',
    overlapHeader: false,
    preventHeader: true,
    plain     : true,
    title: Share.T('切换系统'),
    layout: {
        type: 'absolute'
    },
    y:42,
    x:50,
    style: 'opacity: 0.8;',
    
    initComponent: function(){
    	var me = this;     
        this.title = Share.T('切换系统');
        Ext.applyIf(me, {
        	items: [
        	    {
        	    	xtype:'button',
        	    	width:120,
        	    	heght:30,
        	    	x:10,
        	    	y:10,
        	    	id:'finance_click',
        	    	style: 'opacity: 1;',
                    text:Share.T('切换至FINANCE系统'),
                    listeners: {
                    	click : function(btn,event,eOpts){
                    		ChangeSystem.SysURL_Login = '../HPFS/login';
                    		ChangeSystem.SysURL_Main = '../HPFS/main';
                    		ChangeSystem.ChangeSystem();
                    	}
                    }
        	    },{
        	    	xtype:'button',
        	    	width:120,
        	    	heght:30,
        	    	x:150,
        	    	y:10,
        	    	id:'tax_click',
        	    	style: 'opacity: 1;',
                    text:Share.T('切换至TAX系统')	,
                    listeners: {
                    	click : function(btn,event,eOpts){
                    		ChangeSystem.SysURL_Login = './login';
                    		ChangeSystem.SysURL_Main = './main';
                    		ChangeSystem.ChangeSystem();
                    	}
                    }       
        	    }
        	]
        });
        me.callParent(arguments);
    },
    listeners:{
    	close: function(window,eOpts){
    		ChangeSystem.Change_Sys = 0;
    	}
    }
});